-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add TLS end to end unit test #1
Add TLS end to end unit test #1
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some very minor feedback but otherwise LGTM
@@ -18,4 +18,8 @@ public sealed record ClientTlsOptions | |||
public bool UseTls { get; init; } = false; | |||
|
|||
public SslClientAuthenticationOptions? SslOptions { get; init; } | |||
|
|||
public RemoteCertificateValidationCallback? ServerCertificateValidator { get; set; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are both built into SslClientAuthenticationOptions
https://learn.microsoft.com/en-us/dotnet/api/system.net.security.sslclientauthenticationoptions?view=net-8.0#properties - let's use those properties instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -53,6 +53,9 @@ public MqttClientFactory(ActorSystem system) | |||
public async Task<IMqttClient> CreateTcpClient(MqttClientConnectOptions options, MqttClientTcpOptions tcpOptions) | |||
{ | |||
AssertMqtt311(options); | |||
if (tcpOptions.TlsOptions is { UseTls: true, SslOptions: null }) | |||
throw new NullReferenceException("TlsOptions.SslOptions can not be null if TlsOptions.UseTls is true"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
public SslServerAuthenticationOptions? SslOptions { get; set; } | ||
public SslServerAuthenticationOptions? SslOptions { get; init; } | ||
|
||
public RemoteCertificateValidationCallback? ClientCertificateValidator { get; init; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same feedback as earlier - SslServerAuthenticationOptions
also contains these properties: https://learn.microsoft.com/en-us/dotnet/api/system.net.security.sslserverauthenticationoptions?view=net-8.0 - let's use those
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@@ -0,0 +1,17 @@ | |||
-----BEGIN CERTIFICATE REQUEST----- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did my old certs not work correctly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also needed the self-signed root CA certificate that signs the server certificate, that's why I needed to rebuild all of the certs
} | ||
|
||
[Fact] | ||
public async Task ShouldAutomaticallyReconnectAndSubscribeAfterServerDisconnect() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be better if we just made the TCP end 2 end specs sub-classable and reuse those @Arkatufus ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can give that a try
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
No description provided.